package com.ruoyi.web.controller.news.api;

import com.github.pagehelper.PageInfo;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.domain.news.NewsInspectManage;
import com.ruoyi.system.domain.news.query.NewsInspectManageQuery;
import com.ruoyi.system.domain.news.vo.NewsInspectManageVo;
import com.ruoyi.system.service.news.NewsInspectManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/news/newsInspectManage")
@Api(value = "newsInspectManageApiController", tags  = "监督管理Api")
public class NewsInspectManageApiController extends BaseController {

	@Resource
	private NewsInspectManageService newsInspectManageService;

	@ApiOperation(value = "获取单个监督管理信息", notes = "获取单个监督管理信息")
	@GetMapping("/getById")
	public R<NewsInspectManage> getById(@RequestParam(value = "id") Long id) {
		NewsInspectManageQuery newsInspectManageQuery = new NewsInspectManageQuery();
		newsInspectManageQuery.setId(id);
		List<NewsInspectManageVo> newsInspectManageList = newsInspectManageService.getNewsInspectManageList(newsInspectManageQuery);
		if (newsInspectManageList!=null&&newsInspectManageList.size()>0) {
			return R.ok(newsInspectManageList.get(0));
		} else {
			return R.fail("数据不存在");
		}
	}

	@ApiOperation(value = "获取监督管理信息列表")
	@PostMapping(value = "/list")
	public R<PageInfo<NewsInspectManageVo>> list(@RequestBody NewsInspectManageQuery newsInspectManageQuery) {
        newsInspectManageQuery.setIsEnable("1");
		List<NewsInspectManageVo> newsInspectManageList = newsInspectManageService.getNewsInspectManageList(newsInspectManageQuery);
		return R.ok(new PageInfo<>(newsInspectManageList));
	}
}
